package com.imooc.es_demo.repository.mysql;

import com.imooc.es_demo.entity.mysql.MysqlBlog;
import org.hibernate.annotations.Parameter;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface MysqlBlogRepository extends JpaRepository<MysqlBlog,Integer> {

    @Query("select e from MysqlBlog e order by e.createTime desc ")
    List<MysqlBlog> queryAll();

    @Query("select e from MysqlBlog e where e.title like concat('%',:keyword,'%') or e.content like concat('%',:keyword,'%') ")
    List<MysqlBlog> queryMysqlBlogsByTitleLikeOrContentLike(@Param("keyword") String keyword);
}
